var task1 = function () {
  return new Promise(function (resolve, reject) {
    resolve(100)
  })
}

var task2 = function () {
  return new Promise(function (resolve, reject) {
    resolve(200)
  })
}


function* main() {
  const a = yield task1();
  console.log(a)

  const b = yield task2();
  console.log(b)
}

const g = main();

const result = g.next();

result.value.then(data => {
  const result2 = g.next(data);
  if (result2.done) return;
  result2.value.then(data => {
    const result3 = g.next(data)
    if (result3.done) return;
    result3.value.then(data => {
      g.next(data)
    })
  })
})

